package com.zhuiyun.project.api.article.controller;

import com.zhuiyun.project.api.article.entity.ArticleAudit;
import com.zhuiyun.project.api.article.service.ArticleReviewService;
import com.zhuiyun.project.common.controller.BaseController;
import com.zhuiyun.project.common.response.CommonResult;
import com.zhuiyun.project.util.pageUtil.PageRequest;
import com.zhuiyun.project.util.pageUtil.PageResult;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.websocket.Session;
import java.util.Date;
import java.util.List;

/**
 * @ClassName ArticleReviewController
 * @Description TODO 文章审核
 * @Author maomao
 * @Date 2023/6/5 16:03
 **/
@CrossOrigin
@RestController
@RequestMapping("/articleReview")
@Api(tags = "文章审核模块")
@Slf4j
public class ArticleReviewController extends BaseController {

    @Autowired
    ArticleReviewService articleReviewService;

    /**
    * @Author mao
    * @Description TODO 查询出待审核的文章
    * @Date 2023/6/23 9:32
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param pageRequest
    * @param userName
    * @param articleTitle
    */
    @GetMapping("/getArticle")
    public CommonResult getArticle(PageRequest pageRequest, String userName, String articleTitle) {
        // 调用文章审核服务的getArticle方法，获取文章结果
        PageResult pageResult = articleReviewService.getArticle(pageRequest,userName, articleTitle);
        // 返回包含文章结果的通用响应对象
        return CommonResult.ok(pageResult);
    }

    /**
     * 文章审核通过
     * @author 温
     * @date 2023/7/17 19:10
     * @parameter [articleAudit]
     * @return com.zhuiyun.project.common.response.CommonResult
     */
    @PostMapping("/addArticleStatus")
    public CommonResult addArticleStatus(@RequestBody ArticleAudit articleAudit){
        return articleReviewService.addArticleStatus(articleAudit);
    }



    /**
     * 文章审核驳回
     * @author 温
     * @date 2023/7/17 19:10
     * @parameter [articleAudit]
     * @return com.zhuiyun.project.common.response.CommonResult
     */
    @PostMapping("/addArticleUpdate")
    public CommonResult addArticleUpdate(@RequestBody ArticleAudit articleAudit){
        return articleReviewService.addArticleUpdate(articleAudit);
    }


/**
 * 审核记录
 * @author 温
 * @date 2023/7/18 10:39
 * @parameter [pageRequest]
 * @return com.zhuiyun.project.common.response.CommonResult
 */
    @GetMapping("/ArticleAuditList")
    public CommonResult ArticleAuditList(String articleTitle,PageRequest pageRequest){
        PageResult pageResult = articleReviewService.ArticleAuditList(articleTitle,pageRequest);
        return CommonResult.ok(pageResult);
    }
}
